﻿namespace UnityEditor
{
    using System;

    public class VCMenuPending
    {
        [UnityEditor.MenuItem("CONTEXT/Pending/Diff Against Head...", false, 400)]
        private static void DiffHead(MenuCommand cmd)
        {
            VCProvider.DiffHead(VCListControl.FromID(cmd.userData).SelectedAssets);
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/Diff Against Head...", true)]
        private static bool DiffHeadTest(MenuCommand cmd)
        {
            return VCProvider.DiffIsValid(VCListControl.FromID(cmd.userData).SelectedAssets);
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/Lock", false, 300)]
        private static void Lock(MenuCommand cmd)
        {
            VCAssetList selectedAssets = VCListControl.FromID(cmd.userData).SelectedAssets;
            VCProvider.Lock(selectedAssets, true);
            VCDatabase.Invalidate(selectedAssets);
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/Lock", true)]
        private static bool LockTest(MenuCommand cmd)
        {
            return VCProvider.LockIsValid(VCListControl.FromID(cmd.userData).SelectedAssets);
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/New Changelist...", false, 0x1f5)]
        private static void MoveToChangelist(MenuCommand cmd)
        {
            VCWindowChange.Open(VCListControl.FromID(cmd.userData).SelectedAssets, false);
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/New Changelist...", true)]
        private static bool NewChangelistTest(MenuCommand cmd)
        {
            return VCProvider.isActive;
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/Revert...", false, 200)]
        private static void Revert(MenuCommand cmd)
        {
            VCWindowRevert.Open(VCListControl.FromID(cmd.userData).SelectedAssets);
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/Revert...", true)]
        private static bool RevertTest(MenuCommand cmd)
        {
            return VCProvider.RevertIsValid(VCListControl.FromID(cmd.userData).SelectedAssets, false);
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/Revert Unchanged", false, 0xc9)]
        private static void RevertUnchanged(MenuCommand cmd)
        {
            VCAssetList selectedAssets = VCListControl.FromID(cmd.userData).SelectedAssets;
            VCProvider.Revert(selectedAssets, true);
            VCDatabase.Invalidate(selectedAssets);
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/Revert Unchanged", true)]
        private static bool RevertUnchangedTest(MenuCommand cmd)
        {
            return VCProvider.RevertIsValid(VCListControl.FromID(cmd.userData).SelectedAssets, true);
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/Show in Explorer...", false, 0x191)]
        private static void ShowInExplorer(MenuCommand cmd)
        {
            EditorApplication.ExecuteMenuItem("Assets/Show in Explorer");
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/Show in Explorer...", true)]
        private static bool ShowInExplorerTest(MenuCommand cmd)
        {
            return (VCListControl.FromID(cmd.userData).SelectedAssets.Count > 0);
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/Submit...", false, 100)]
        private static void Submit(MenuCommand cmd)
        {
            VCWindowChange.Open(VCListControl.FromID(cmd.userData).SelectedAssets, true);
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/Submit...", true)]
        private static bool SubmitTest(MenuCommand cmd)
        {
            return VCProvider.SubmitIsValid(null, VCListControl.FromID(cmd.userData).SelectedAssets);
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/Unlock", false, 0x12d)]
        private static void Unlock(MenuCommand cmd)
        {
            VCAssetList selectedAssets = VCListControl.FromID(cmd.userData).SelectedAssets;
            VCProvider.Lock(selectedAssets, false);
            VCDatabase.Invalidate(selectedAssets);
        }

        [UnityEditor.MenuItem("CONTEXT/Pending/Unlock", true)]
        private static bool UnlockTest(MenuCommand cmd)
        {
            return VCProvider.UnlockIsValid(VCListControl.FromID(cmd.userData).SelectedAssets);
        }
    }
}

